<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用axios测试某一接口</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.0/axios.min.js"></script>
</head>
<body>
    <button id="btn">发送请求</button>
    <script>
        const btn = document.querySelector('#btn')

        btn.addEventListener('click', function () {
            /*
			axios.get('http://172.31.118.238:3000/get/version', {
                params: {
                app: 'wyt',
                type: 2,
                version: '2.0'
                }
            }).then((res) => {
                console.log(res);
            })
			*/

            // 如果需要提交的数据是 x-www-form-urlencoded形式
			var formData = new FormData();
			formData.append('_api_key','06db25bfd53cdf41c128a5d0cd748150');
			formData.append('appKey','86c8ceec1a4d8d473ab8b1f64a6bacb2');
			formData.append('buildVersion','1.0');
			
			/*
			{
                '_api_key': '06db25bfd53cdf41c128a5d0cd748150',
				'appKey': '86c8ceec1a4d8d473ab8b1f64a6bacb2',
				'buildVersion': '1.0'
            }
			*/
			axios.post('https://www.pgyer.com/apiv2/app/check', formData, {headers: {'content-type': 'application/x-www-form-urlencoded'}}).then((res) => {
                console.log(res);
            })
        })
    </script>
</body>
</html>